home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Shape.c
-
- Copyright (c) 1996, Adobe Systems Incorporated.
- All rights reserved.
-
- */
-
- #if __MWERKS__
- #include <SetupA4.h> // A4-globals
- #include <A4Stuff.h> // A4-globals
- #endif
-
- #if defined(THINK_C) || defined(__MWERKS__)
- #define ENTRYPOINT main
- #endif
-
- #include "Shape.h"
-
- Handle hDllInstance = NULL;
-
- /*****************************************************************************/
-
- void InitGlobals (GPtr globals);
- void DoExecute (GPtr globals);
-
- /*****************************************************************************/
-
- /* All calls to the plug-in module come through this routine. It must be
- placed first in the resource. To achieve this, most development systems
- require that this be the first routine in the source. */
-
- #if MSWindows
- void ENTRYPOINT (short selector,
- PISelectionParams *selectionParamBlock,
- long *data,
- short *result)
- #else
- pascal void ENTRYPOINT (short selector,
- PISelectionParams *selectionParamBlock,
- long *data,
- short *result)
- #endif
- {
-
- Globals globalValues;
- GPtr globals = &globalValues;
-
- #if __MWERKS__
- EnterCodeResource(); // A4-globals
- #endif
-
- if (!*data)
- {
-
- InitGlobals (globals);
-
- *data = (long) NewHandle (sizeof (Globals));
-
- if (!*data)
- {
- *result = memFullErr;
- return;
- }
-
- ** (GHdl) *data = globalValues;
-
- }
-
- globalValues = ** (GHdl) *data;
-
- gStuff = selectionParamBlock;
- gResult = noErr;
-
- switch (selector)
- {
-
- case selectionSelectorAbout:
- DoAbout (globals);
- break;
-
- case selectionSelectorExecute:
- DoExecute (globals);
- break;
-
- default:
- gResult = selectionBadParameters;
- }
-
- *result = gResult;
- ** (GHdl) *data = globalValues;
-
- #if __MWERKS__
- ExitCodeResource(); // A4-globals
- #endif
- }
-
- /*****************************************************************************/
-
- void InitGlobals (GPtr globals)
- {
- gWhatShape = iShapeTriangle;
- gCreate = iCreateSelection;
- gQueryForParameters = true;
- }
-
- /*****************************************************************************/
-
- void DoExecute (GPtr globals)
- {
- Boolean doThis = true;
- int32 size = 0; // DWORD int32 size;
- Ptr p = NULL; // LPVOID Ptr hPtr;
-
- gQueryForParameters = ReadScriptParams (globals);
-
- if ( gQueryForParameters ) doThis = DoParameters (globals);
-
- if ( doThis )
- {
- p = PIGetResource (PathResource, (int32)(ResourceID+gWhatShape), &size);
- if (p == NULL || size < 1)
- {
- gResult = -1;
- return;
- }
-
- gStuff->newPath = PINewHandle (size);
-
- if (gStuff->newPath == NULL)
- {
- gResult = memFullErr;
- return;
- }
-
- memcpy(*gStuff->newPath, p, size);
- PIReleaseResource(p);
-
- /* look in gStuff->supportedTreatments for support for this next thang */
-
- gStuff->treatment = KeyToEnum(EnumToKey(gCreate,typeCreate),typePISel);
-
- WriteScriptParams (globals);
- } // user cancelled or dialog err or silent
- }
-
-